<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@include file="/common/taglibs.jsp"%>
<html>
<head>
<%@include file="/common/ec.jsp"%>
<%@include file="/common/extjs.jsp" %>
<%@include file="/common/meta.jsp"%>
<script type="text/javascript">
function removeOrder(orderId){
    Ext.MessageBox.confirm('提示','确实要删除此订单吗？', function(btn){
        if (btn == 'yes') {
           window.location.href="remove.do?model.id="+ orderId;
        }
    });	
}

</script>
<title>订单信息浏览</title>
</head>
<body>
<div class="x-panel">
<div class="x-panel-header">订单管理</div>
<div class="x-toolbar">
<table width="99%">
  <tr>
    <td><s:form action="index.do" method="post"> 
           订单编号：<s:textfield id="sn" name="model.sn" cssStyle="width:100px;"></s:textfield> 
           订单用户     <s:textfield id="user" name="model.user.name" cssStyle="width:100px;"></s:textfield>
           下单日期：<input type="text" name="createBeginDate" style="width: 120px"
				value='<s:date name="createBeginDate" format="yyyy-MM-dd"/>'
				onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"
				class="Wdate" />
						</>至
			<input type="text" name="createEndDate" style="width: 120px"
				value='<s:date name="createEndDate" format="yyyy-MM-dd"/>'
				onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'})"
				class="Wdate" />
	<%--付款日期：<s:textfield name="model.payDate" size="8"></s:textfield> --%>
                  
           状          态：<s:select list="statusMap" name="model.status" headerKey="" headerValue="请选择"></s:select>     
      <input type="submit" value="查询" class="button" />
    </s:form>
    </td>
  </tr>
</table>
</div>
<div class="x-panel-body">
<div style="margin-left: -3px;" align="center">
<ec:table
  items="items" var="item" retrieveRowsCallback="limit" sortRowsCallback="limit" 
  action="index.do" 
  useAjax="false"
  doPreload="false" 
  pageSizeList="20,50,100,200" 
  editable="false"
  sortable="true" 
  rowsDisplayed="20" 
  generateScript="true"
  resizeColWidth="false" 
  classic="false" 
  width="100%" 
  height="400px"
  minHeight="400"
  toolbarContent="navigation|pagejump|pagesize|refresh|extend|status">
  <ec:row>
    <ec:column width="40" property="_num" title="No." value="${GLOBALROWCOUNT}" sortable="false" style="text-align:center"/> 
    <ec:column width="150" property="_title" title="订单编号" sortable="false"  style="text-align:center"> 
  	   <a href="edit.do?model.id=${item.id}"><font color="blue">${item.sn}</font></a> 
    </ec:column> 
    <ec:column width="150" property="_title" title="图书"  sortable="false" style="text-align:center"> 
  	  	<c:forEach items="${item.items}" var="orderItem">
			<div style="width: 50px;height: 50px;">
				<a target="_blank"   	href="" 	name="productpic" title="">
  					<img src="${ctx}${orderItem.book.coverPhoto}"  style="width: 50px;height: 50px;" alt="22">
  				</a>
			</div>
		</c:forEach> 
    </ec:column>
    <ec:column width="130" property="user.name" title="下单人"  sortable="false" style="text-align:center"/>  
    <ec:column width="100" property="createDate"  title="下单日期"  sortable="false"  cell="date"  style="text-align:center">
    </ec:column>
    <ec:column width="100" property="payDate"  title="支付日期"  sortable="false" cell="date" style="text-align:center"/>
    <ec:column width="70" property="money" title="金额"   sortable="false" style="text-align:center"  />     
    <ec:column width="80" property="status" title="订单状态"  sortable="false" style="text-align:center">
       <c:choose>
         <c:when test="${item.status eq '0'}">
         	待审核
         </c:when>
         <c:when test="${item.status eq '1'}">
         	取消[系统]
         </c:when>
         <c:when test="${item.status eq '2'}">
         	确认[未付款]
         </c:when>
         <c:when test="${item.status eq '3'}">
         	已付款
         </c:when>
         <c:when test="${item.status eq '4'}">
         	已发货
         </c:when>
         <c:when test="${item.status eq '5'}">
         	结单
         </c:when>
         <c:when test="${item.status eq '6'}">
         	取消[用户]
         </c:when>
         <c:when test="${item.status eq '7'}">
         	系统删除
         </c:when>
       </c:choose>
    </ec:column>    
		    
    <ec:column width="180" property="_0" title="操作" style="text-align:center" sortable="false">
    <a href="edit.do?model.id=${item.id}"><font color="blue">查看</font></a> |	 
    <%--
        <c:choose>
        	<c:when test="${item.status eq '0'}">
        		<a href="edit.do?model.id=${item.id}">审核</a> |
        	</c:when>
        	<c:when test="${item.status eq '1'}">
        		<a href="#" onclick="operation(${item.id},'1')">支付</a> |
        	</c:when>
        	<c:when test="${item.status eq '3'}">
        		<a href="#" onclick="operation(${item.id},'3')">发货</a> |
        	</c:when>
        	<c:when test="${item.status eq '4'}">
        		<a href="#" onclick="operation(${item.id},'4')">结单</a> |
        	</c:when>
        </c:choose>  
     --%>            
	  	<c:choose>
	  		<c:when test="${item.status eq '0' or item.status eq '1' or item.status eq '2'}">  		   
	  		    <a href="#" onClick="removeOrder(${item.id})">删除</a>
	  		</c:when>
	  		<c:otherwise>
	  			<font color="#999999">删除</font>
	  		</c:otherwise>
	  	</c:choose>	          
	</ec:column>    
  </ec:row>
</ec:table>
</div>
</div>
</div>
<script type="text/javascript">
function operation(itemId,arg){
	var message;
	if(arg == '1'){
		message = '此订单确认支付?';
	}else if(arg == '3'){
		message = '此订单确认发货?';
	}else{
		message = '此订单结单?';
	}
	Ext.MessageBox.confirm('提示',message, function(btn){
        if (btn == 'yes') {
           window.location.href="operation.do?model.id="+ itemId;
        }
    });
}

</script>
</body>
</html>